/**
 * Created by chenyong on 2015/11/20.
 * 调用景坤Service时的异常捕捉
 */

/**
 * 使用Request调用Chingkun Service时引发的异常
 * @param message   异常信息
 * @param status    Http状态代码
 * @constructor
 */
function ServiceRequestError(message, status)
{
    Error.call(this);
    Error.captureStackTrace(this, arguments.callee);
    this.name = 'ServiceRequestError';
    this.message = message || "调用ChingkunService时引发Request错误";
    this.status = status || 500;
}
ServiceRequestError.prototype.__proto__ = Error.prototype;


/**
 * 调用Chingkun Service时引发的一般性异常
 * @param error     异常信息，可以是字符串、也可以是Error实例
 * @constructor
 */
function ServiceGeneralError(error)
{
    Error.call(this);
    Error.captureStackTrace(this, arguments.callee);
    this.name = "ServiceGeneralError";
    this.message = "调用ChingkunService时引发一般性错误";
    this.status = 500;

    if(error && error instanceof Error)
    {
        this.message = error.message;
    }
    else if(typeof error =="string")
    {
        this.message = error;
    }

}
ServiceGeneralError.prototype.__proto__ = Error.prototype;

exports.ServiceRequestError = ServiceRequestError;
exports.ServiceGeneralError = ServiceGeneralError;